package com.se.frontline.gameplay.units;

import org.andengine.engine.handler.IUpdateHandler;
import org.andengine.entity.modifier.MoveXModifier;
import org.andengine.entity.sprite.AnimatedSprite;
import org.andengine.entity.sprite.AnimatedSprite.IAnimationListener;
import org.andengine.entity.sprite.Sprite;
import org.andengine.entity.sprite.TiledSprite;

import com.se.frontline.gameplay.ManagedGameScene;
import com.se.frontline.managers.ResourceManager;

public class Unit3 extends Unit {
	
	private AnimatedSprite Unit3Sprite;
	private MoveXModifier move;
	public float Height;
	public float Width;
	public boolean isEnemy;
	
	//====================================================
	// Statistics of this Unit
	//====================================================
	
	private int Health;
	private int Damage;
	private int Armor;
	

	public Unit3(boolean pIsEnemy){


		isEnemy = pIsEnemy;
		if(isEnemy==false){
		Unit3Sprite = new AnimatedSprite(-50, 0, ResourceManager.getInstance().mUnit3TextureRegion,
						ResourceManager.getInstance().engine.getVertexBufferObjectManager());}
		if(isEnemy==true){
			Unit3Sprite = new AnimatedSprite(-50, 0, ResourceManager.getInstance().mUnit3TextureRegion,
							ResourceManager.getInstance().engine.getVertexBufferObjectManager());
			Unit3Sprite.setFlippedHorizontal(true);}
			
				Unit3Sprite.animate(300);
				
				this.Height = Unit3Sprite.getHeight();
				this.Width = Unit3Sprite.getWidth();

	}
	
	@Override
	public void go(float pY, Unit myself) {
		
		
		Unit3Sprite.setY(pY);
		if(Unit3.this.isEnemy==false){move = new MoveXModifier(20, -50, 1800);}
		else if(Unit3.this.isEnemy==true){move = new MoveXModifier(5, 1650, -100);}
		Unit3Sprite.registerEntityModifier(move);
		ResourceManager.getInstance().getGameGround().attachChild(Unit3Sprite);
		Unit3Sprite.setUserData(myself);
	}
	
	@Override
	public float getHeight() {
		return Height;
	}
	
	public Sprite getSprite()
	{
		return Unit3Sprite;
	}
	
	public void fight(Unit enemy)
	{
		Unit3Sprite.unregisterEntityModifier(move);
	
	}

}
